import Vue from 'vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        name: 'home',
        meta: { title: "约起来 - 首页" },
        component: () => import('views/home')
    },
    {
        path: '/index/release1',
        name: 'release1',
        meta: { title: "约起来 - 活动发布" },
        component: () => import('views/release/index'),
        children:[
            {
                path: '/index/release',
                name: 'release',
                meta: { title: "约起来 - 活动发布" },
                component: () => import('views/release/release')
            },
            {
                path: '/index/release/detailed',
                name: 'detailed',
                meta: { title: "约起来 - 活动详细" },
                component: () => import('views/release/detailed')
            },
            {
                path: '/index/release/amount',
                name: 'amount',
                meta: { title: "约起来 - 活动人数" },
                component: () => import('views/release/amount')
            },
            {
                path: '/index/release/time',
                name: 'release_time',
                meta: { title: "约起来 - 活动时间" },
                component: () => import('views/release/time')
            },
            {
                path: '/index/release/address',
                name: 'address',
                meta: { title: "约起来 - 活动地址" },
                component: () => import('views/release/address')
            },
        ]
    },


]

const router = new VueRouter({
    mode:'history',
    routes
})

// 没设置标题就打不开
router.beforeEach((to, from, next) => {
    if (to.meta.title) {
        document.title = to.meta.title
    }
    next()
})

export default router